#include "Signal.h"

Signal::Signal()
{
	
}

Signal::Signal(UInt16 _rawMax, UInt16 _rawMin, UInt16 _physMax, UInt16 _physMin)
{
	rawMax = _rawMax;
	rawMin = _rawMin;
	physMax = _physMax;
	physMin = _physMin;
	rawValue = 0u;
	physValue= 0u;
}

UInt16 Signal::raw2phys(UInt16 raw)
{
	UInt32 value = raw;
	value *= physMax - physMin;
	value /= rawMax - rawMin;
	value += physMin;
	return (UInt16)value;
}

UInt16 Signal::phys2raw(UInt16 phys)
{
	UInt32 value = phys;
	value *= rawMax - rawMin;
	value /= physMax - physMin;
	value += rawMin;
	return (UInt16)value;
}